export function updateCarApi(car, header, callback) {

    $.ajax({
        url: header.host + '/car/updateCar',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "car": car

        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function addCarApi(car, header, callback) {

    $.ajax({
        url: header.host + '/car/addCar',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "car": car
                // "car": {
                //     "name": name,
                //     "brand": brand,
                //     "chepai": chepai,
                // },

        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function getCarsApi(page, pagesize, filter, header, callback) {
    $.ajax({
        url: header.host + '/car/getCars',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "page": page,
            "pagesize": pagesize,
            "filter": filter
        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}

